
package com.probiz.estore.customer.dao.impl;

import java.util.List;

import com.probiz.estore.common.model.customer.ShopPointHistory;
import com.probiz.estore.common.model.customer.ShopPointHistory.FilterHqlName;
import com.probiz.estore.core.dao.impl.HibernateGenericDaoImpl;
import com.probiz.estore.customer.dao.ShopPointHistoryDao;

/**
 * ShopPointHistory Data Access Object (DAO) implementation. Developer
 * introduced interfaces should be declared here. Won't get overwritten.
 */
public class ShopPointHistoryDaoImpl extends HibernateGenericDaoImpl<ShopPointHistory> implements ShopPointHistoryDao {

	@Override
	protected void initFilterHqlMap() {
		filterHqlMap.put(FilterHqlName.MY_HISTORY_LIST, "from ShopPointHistory s where s.customer.appuserId = ? order by s.createTime desc");
	}
	
	
	/*
	 * (non-Javadoc)
	 * @see com.probiz.estore.customer.dao.ShopPointHistoryDao#getByCustomerIdAndTypeAndEntityId(java.lang.Integer, java.lang.Short, java.lang.Integer)
	 */
	public ShopPointHistory getByCustomerIdAndTypeAndEntityId(Integer customerId,Short type,Integer entityId){
		List<ShopPointHistory> list = this.findByHql("from ShopPointHistory s where s.customer.appuserId = ? and s.shopPointType = ? and entityId = ?",customerId, type,entityId);
		if(list.size()>0){
			return list.get(0);
		}else{
			return null;
		}
	}
	

}